import React from 'react';
//HashRouter原本是BrowserRouter的，后面改成HashRouter，因为上线后BrowserRouter刷新页面会报404错误，改成HashRouter就不会了，
//虽然说可以设置，让BrowserRouter不报错，但是没必要，直接改成HashRouter就可以解决
import { HashRouter as Router, Route, Switch } from "react-router-dom";

import LoginPage from "./pages/Login";
import IndexPage from "./pages/Index";

import CoursePage from './pages/Sub/Course';
import RecomCoursePage from './pages/Sub/RecomCourse';
import SliderPage from './pages/Sub/Slider';
import CollectionPage from './pages/Sub/Collection';
import TeacherPage from './pages/Sub/Teacher';
import StudentPage from './pages/Sub/Student';
import CrawlerPage from './pages/Sub/Crawler';
import ErrorPage from "./pages/Sub/Error";

function App() {
  return (
    <Router>

      <Switch>
        <Route component={ LoginPage } path="/login" />
        <Route path="/" render={ props => (
          <IndexPage history={ props.history }>
            <Switch>
               <Route component={ CoursePage } path="/course" />
               <Route component={ RecomCoursePage } path="/recom_course" />
               <Route component={ SliderPage } path="/slider" />
               <Route component={ CollectionPage } path="/collection" />
               <Route component={ TeacherPage } path="/teacher" />
               <Route component={ StudentPage } path="/student" />
               <Route component={ CrawlerPage } path="/crawler" />
               <Route component={ ErrorPage } /> {/*404页面，react是从上往下匹配的，只要没匹配到，就会走404这个组件 */}
            </Switch>
          </IndexPage>
        )} />
      </Switch>
      
    </Router>
  );
}

export default App;
